﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Globalization;
namespace QuanLyKhachSan
{
    public partial class UC_Phong_GiaPhong : System.Web.UI.UserControl
    {        
        /// <summary>
        /// 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>        
        protected void Page_Load(object sender, EventArgs e)
        {

            if (!Page.IsPostBack)
            {
                GiaPhong_Load();
            }
        }
        protected void GiaPhong_Load()
        {
            try
            {
                //Load Danh Sách Phòng
                dlGiaPhong.DataSource = Gia_PhongBLL.Phong_GiaPhong();
                dlGiaPhong.DataBind();
            }
            catch (Exception ex)
            {                
                throw ex;
            }
        }
        public string Format_NumberVietnamese(string Gia)
        {
            try
            {
                decimal value = decimal.Parse(Gia);
                string retGia = value.ToString("N", CultureInfo.CreateSpecificCulture("vi-VN"));
                return retGia.Replace(",00","");
            }
            catch (Exception)
            {

                throw;
            }
        }
        public string Format_GiaGio(string GiaGio)
        {
            try
            {
                string retGiaGio = "";                
                string[] aGiaGio = GiaGio.Split(("|").ToCharArray());                
                for (var i = 0; i < aGiaGio.Length; i++)
                {
                    if (aGiaGio[i] != "")
                    {
                        string[] aItem = aGiaGio[i].ToString().Split((";").ToCharArray());
                        retGiaGio += "<div>" + aItem[0] + "h:" + Format_NumberVietnamese(aItem[1]) + "</div>";
                    }
                }                
                return retGiaGio;
            }
            catch (Exception)
            {
                
                throw;
            }
        }
}
}

